package SocialNetwork.actions;


import java.util.*;

import Dominion.Sistema;
import Dominion.Author;
import Dominion.Article;
import Dominion.User;



import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class SendPublications extends ActionSupport{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	private boolean checkvip;
	private String publicationname;
	private String comentarticle;
	private String tag;
	
	public String execute() {
		Author a;
		User u; 
		try {
			Map<String, Object> session = ActionContext.getContext().getSession();  // Get session
			u =  (User) session.get("user"); 
			a = new Author(u);
			Sistema s = new Sistema();
			
			Article Art = new Article();
			Art.setTitle(publicationname);
			Art.setComment_author(comentarticle);
			Art.setId_author(a.getEmail());
			Art.setPublishing_date(utilidades.leer.fecha());
			
			if(checkvip==true){
				Art = a.send_publication(Art, 1);
			}
			else{ 
				Art = a.send_publication(Art, 0);
			}


			a.set_articleTag(Art, tag);
			s.PublicationsToReviewer(Art);
			return SUCCESS; 
		}
		catch (Exception e) {
			return ERROR;
		}
	}

	
	public void setCheckvip(boolean checkvip){
		System.out.println(checkvip);
		 this.checkvip=checkvip; 
	}

	public void setPublicationname(String publicationname){
		this.publicationname=publicationname;
	}
	
	public void setComentarticle(String comentarticle){
		this.comentarticle=comentarticle;
	}
	public void setTag(String tag){
		this.tag = tag; 
	}
}
